home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
HENSA
/
MISC
/
SENDMAIL.ARC
/
c
/
putmail
next >
Wrap
Text File
|
1993-10-04
|
887b
|
48 lines
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define BUFFLEN 1024
char buffer[BUFFLEN];
void usage()
{
fprintf( stderr, "Usage: putmail user\n" );
exit( 1 );
}
FILE *infile;
FILE *outfile;
int main( int argc, char **argv )
{
char *buff;
if( argc!=2 ) usage();
infile = stdin;
sprintf( buffer, "<Mail$dir>.spool.mail.text.%s", argv[1] );
if( ! (outfile=fopen(buffer,"a")) ) {
fprintf( stderr, "unable to open mail box\n" );
exit( 1 );
}
/* we do no file locking ! */
buff = fgets( buffer, BUFFLEN-1, infile );
if( memcmp( buffer, "From ", 5 ) ) {
time_t atim;
time( &atim );
fprintf( outfile, "From %s", ctime( &atim ));
}
while( buff==buffer ) {
fputs( buffer, outfile );
buff = fgets( buffer, BUFFLEN-1, infile );
}
fprintf( outfile, "\n" );
fclose( infile );
fclose( outfile );
return 0;
}